<script setup lang="ts" name="NoticeBarProperty">
import { NoticeBarProperty } from './config'
import { usePropertyForm } from '@/components/Designer/utils/index'
// 通知栏属性面板
// 表单校验
const rules = {
  content: [{ required: true, message: '请输入公告', trigger: 'blur' }]
}

const props = defineProps<{ modelValue: NoticeBarProperty }>()
const emit = defineEmits(['update:modelValue'])
const { formData } = usePropertyForm(props.modelValue, emit)
</script>

<template>
  <MallProperty v-model="formData.style">
    <ElForm label-width="80px" :model="formData" :rules="rules">
      <ElFormItem label="公告图标" prop="iconUrl">
        <UploadImage v-model="formData.iconUrl" height="48px">
          <template #tip>建议尺寸：24 * 24</template>
        </UploadImage>
      </ElFormItem>
      <ElFormItem label="背景颜色" prop="backgroundColor">
        <ColorInput v-model="formData.backgroundColor" />
      </ElFormItem>
      <ElFormItem label="文字颜色" prop="文字颜色">
        <ColorInput v-model="formData.textColor" />
      </ElFormItem>
      <ElCard header="公告内容" class="property-group" shadow="never">
        <Draggable v-model="formData.contents">
          <template #default="{ element }">
            <ElFormItem label="公告" prop="text" label-width="40px">
              <ElInput v-model="element.text" placeholder="请输入公告" />
            </ElFormItem>
            <ElFormItem label="链接" prop="url" label-width="40px">
              <MallAppLinkInput v-model="element.url" />
            </ElFormItem>
          </template>
        </Draggable>
      </ElCard>
    </ElForm>
  </MallProperty>
</template>

<style scoped lang="scss"></style>
